package com.threeox.commonlibrary.ui.view.loadview;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.threeox.commonlibrary.R;
import com.threeox.utillibrary.util.res.LayoutUtils;

/**
 *
 * @ClassName: LoadDialog
 *
 * @Description: TODO(加载中的Dialog)
 *
 * @author 赵屈犇
 *
 * @date 创建时间: 2017/7/8 11:58
 *
 * @version 1.0
 *
 */
@SuppressLint("InlinedApi")
public class LoadDialog extends Dialog implements ILoadDialog {

    protected Context mContext;
    protected TextView mTipTextView;

	public LoadDialog(Context context) {
		this(context, R.style.loading_dialog);
	}

    public LoadDialog(Context context, int themeResId) {
        super(context, themeResId);
        this.mContext = context;
        initLoad();
    }

    private void initLoad() {
        View view = LayoutUtils.inflate(mContext, R.layout.view_load_dialog);
        LinearLayout layout = (LinearLayout) view.findViewById(R.id.dialog_linear);// 加载布局
		mTipTextView = (TextView) view.findViewById(R.id.id_load_text);
		this.setContentView(layout, new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.MATCH_PARENT,
				LinearLayout.LayoutParams.MATCH_PARENT));// 设置布局
	}

    @Override
    public ILoadDialog setMessage(CharSequence msg) {
        if (mTipTextView != null)
            mTipTextView.setText(msg);
        return this;
    }

}
